package drds.server.config.cluster;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import drds.server.config.Node;

/**
 * 
 * @author 曹正辉<330937205@qq.com>
 */
public final class Cluster {

	private final Map<String, Node> nodeMap;
	private final Map<String, List<String>> groups;

	public Cluster(ClusterConfig clusterConfig) {
		this.nodeMap = new HashMap<String, Node>(clusterConfig.getNodeConfigMap().size());
		this.groups = clusterConfig.getGroups();
		for (ClusterNode nodeConfig : clusterConfig.getNodeConfigMap().values()) {
			String name = nodeConfig.getName();
			Node node = new Node(nodeConfig);
			this.nodeMap.put(name, node);
		}
	}

	public Map<String, Node> getNodeMap() {
		return nodeMap;
	}

	public Map<String, List<String>> getGroups() {
		return groups;
	}

}